/**
 * Created by 1 on 2016/7/5.
 */
Ext.define('Monkey.view.code.Template', {
    extend: 'Ext.panel.Panel',
    xtype: 'codetemplate',

    id: 'codetemplate',
    cls: 'mk-codetemplate',
    controller: 'ctrl-codetemplate',
    layout: 'fit',
    tbar: [{
        xtype: 'tbtext',
        html: '代码模版管理'
    }, '-', {
        icon: 'resources/icons/16/page_add.png',
        text: '新增',
        handler: 'addTemplate'
    }, '-', {
        icon: 'resources/icons/16/page_edit.png',
        text: '修改',
        handler: 'modifyTemplate'
    }, '-', {
        icon: 'resources/icons/16/page_delete.png',
        text: '删除',
        handler: 'removeTemplate'
    }, '->', {
        xtype: 'textfield',
        reference: 'templateName',
        labelAlign: 'right',
        emptyText: '输入要查询模板名称...',
        fieldLabel: '模板名称'
    }, {
        icon: 'resources/icons/16/page_find.png',
        text: '查询',
        handler: 'findTemplate'
    }, {
        icon: 'resources/icons/16/refresh.png',
        text: '重置',
        handler: 'reloadTemplate'
    }],
    initComponent: function () {
        var store = Ext.create('Monkey.store.code.Template');
        this.items = [{
            id: 'tplGrid',
            xtype: 'grid',
            border: false,
            reference: 'templateGrid',
            selType: 'checkboxmodel',
            store: store,
            listeners: {
                rowdblclick: 'rowdblclick'
            },
            bbar: {
                xtype: 'pagingtoolbar',
                pageSize: 10,
                store: store,
                displayInfo: true,
                plugins: new Ext.ux.ProgressBarPager()
            },
            columns: [{
                width: 30,
                xtype: 'rownumberer'
            }, {
                text: 'id',
                dataIndex: 'id',
                hidden: true,
                width: 100
            }, {
                text: '模版名',
                width: 140,
                dataIndex: 'name',
                lock: true
            }, {
                text: '包路径',
                dataIndex: 'packagePath',
                width: 180
            }, {
                text: '类名',
                dataIndex: 'className',
                width: 140
            }, {
                text: '配置参数视图',
                dataIndex: 'view',
                width: 140
            }, {
                text: '创建时间',
                dataIndex: 'createTime',
                width: 150
            }, {
                text: '备注',
                dataIndex: 'remark',
                flex: 1
            }, {
                text: '预览图',
                dataIndex: 'picture',
                width: 150
            }, {
                text: '查看预览图',
                xtype: 'actioncolumn',
                menuDisabled: true,
                sortable: false,
                align: 'center',
                width: 80,
                items: [{
                    icon: 'resources/icons/16/page_white_find.png',
                    tooltip: '查看预览图',
                    handler: 'showUploadPic'
                }]
            }]
        }];
        this.callParent();
    }
});